#ifndef NATURALTREEWIDGETITEM_H
#define NATURALTREEWIDGETITEM_H

#include <QTreeWidgetItem>

bool naturalCompare(const QString& s1,const QString& s2);

class NaturalTreeWidgetItem : public QTreeWidgetItem
{
public:
	inline explicit NaturalTreeWidgetItem(int type = Type) :
		QTreeWidgetItem(type) {}
	inline NaturalTreeWidgetItem(const QStringList &strings, int type = Type) :
		QTreeWidgetItem(strings, type) {}
	inline explicit NaturalTreeWidgetItem(QTreeWidget *view, int type = Type) :
		QTreeWidgetItem(view, type) {}
	inline NaturalTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type = Type) :
		QTreeWidgetItem(view, strings, type) {}
	inline NaturalTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type = Type) :
		QTreeWidgetItem(view, after, type) {}
	inline explicit NaturalTreeWidgetItem(QTreeWidgetItem *parent, int type = Type) :
		QTreeWidgetItem(parent, type) {}
	inline NaturalTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type = Type) :
		QTreeWidgetItem(parent, strings, type) {}
	inline NaturalTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type = Type) :
		QTreeWidgetItem(parent, after, type) {}
	inline NaturalTreeWidgetItem(const QTreeWidgetItem &other) :
		QTreeWidgetItem(other) {}

private:
	inline bool operator<(const QTreeWidgetItem &other) const {
		int column = treeWidget()->sortColumn();
		return naturalCompare(data(column, Qt::DisplayRole).toString().toLower(), other.data(column, Qt::DisplayRole).toString().toLower());
	}
};

#endif // NATURALTREEWIDGETITEM_H
